import {
  Toast
} from "vant";
import cTitle from "components/title";
import {
  scrollMixin
} from "../../../utils/mixin";
export default {
  mixins: [scrollMixin], //加载更多
  data() {
    return {
      list: [],
      page: 1, // 初始页码
      total_page: 0,
      isLoadMore: true,
    };
  },

  components: {
    cTitle
  },
  activated() {
    console.log(localStorage.getItem("uid"), 'uid')
    if (!localStorage.getItem("uid")) {
      this.$router.push(this.fun.getUrl("member"));
      return
    }
    this.getList();
  },
  computed: {

  },

  methods: {
    gotoDetail(id){
        this.$router.push(this.fun.getUrl("yunDetailPage",{id: id}));
    },
    getList() {
      $http.get("ZhengChengYc.getCommisionList", {
          uid: localStorage.getItem("uid"),
        // uid: '50260',
        page: this.page
      }, "加载中").then((res) => {
        if (res.result == 1) {
          console.log(res, 'shuju_list')
          var nextPageData = res.data.data;
          this.list = [...this.list, ...nextPageData];
          this.total_page = res.data.last_page;
          this.isLoadMore = true;

        } else {
          this.isLoadMore = false;
        }
      });
    },
    //获取更多数据
    getMoreData() {
      console.log("hongbao", this.isLoadMore);
      if (!this.isLoadMore) return;
      this.isLoadMore = false; // 防止多次请求分页数据
      if (this.page >= this.total_page) {
        Toast('到底了')
        return;
      } else {
        this.page += 1;
        this.getList();
      }
    },

  }
};